{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "5040\n",
      "7.0\n",
      "3.0\n"
     ]
    }
   ],
   "source": [
    "# 求n!\n",
    "def f(n):\n",
    "    s = 1\n",
    "    for i in range(1,n+1):\n",
    "        s *= i\n",
    "    return s\n",
    "print(f(7))\n",
    "\n",
    "# 求c(n,m)\n",
    "def c(n,m):\n",
    "    return f(n)/f(m)/f(n-m)\n",
    "\n",
    "print(c(7,1))\n",
    "print(c(3,2))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "p1 = c(7,7)*c(23,0)/c(30,7)\n",
    "print(p1)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
